using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace Fotka.Uploader
{
    public partial class FormLogin : Form
    {
        private Thread thrGo;
        private Fotka fotka = new Fotka();

        /// <summary>
        /// Konstruktor - inicjowanie potrzebnych zmiennych
        /// </summary>
        public FormLogin()
        {
            fotka.FormLogin = this;
            fotka.mainForm = true;
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.fotka.RegRead();
        }

        private void btnZaloguj_Click(object sender, EventArgs e)
        {
            if (btnZaloguj.Text == "Zamknij")
            {
                Application.Exit();
            }
            else
            {
                lblInfo.Text = "Logowanie...";
                lblInfo.Visible = true;
                btnZaloguj.Enabled = false;
                fotka.login = txtLogin.Text;
                fotka.passowrd = txtPassword.Text;
                txtLogin.Enabled = false;
                txtPassword.Enabled = false;
                thrGo = new Thread(fotka.go);
                thrGo.Start();
            }
        }

        private void llniemaszKonta_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("iexplore.exe", "http://www.fotka.pl/konto_nowe.php");
        }

        private void llzapomnialesHasla_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("iexplore.exe", "http://www.fotka.pl/haslo.php");
        }

        private void logoBox_Click(object sender, EventArgs e)
        {
            OProgramie ab = new OProgramie();
            ab.ShowDialog();
        }

        private void FormLogin_FormClosed(object sender, FormClosedEventArgs e)
        {
            while (this.Opacity > 0)
            {
                this.Opacity = this.Opacity - 0.1;
                System.Threading.Thread.Sleep(50);
            }
        }
    }
}